<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script>
            function f1(){
                //创建对象方式一
                var obj=new Object();
                obj.name="abc";
                obj.age=23;
                obj.play=function(){
                    alert(this.name+"正在玩");
                };


                console.log(obj.name);
                var filedName="name";
                console.log(obj[filedName]);
                obj.play();
            }


            function f2(){
                //创建对象方式二

                var p=new Person("aaa",54);

                console.log(p.name);
                p.play();
            }

            function Person(name,age){
                this.name=name;
                this.age=age;
                this.play=function(){
                    alert(this.name+"正在玩");
                };
            }


            function f3(){
                //创建对象方式三
                var p={
                    "name":"bbb",
                    "age":21,
                    "play":function(){
                        alert(this.name+"正在玩");
                    }
                };

                p.play();
            }

            function f4(){
                var s="{'name':'ccc','age':12}";

                var obj=eval("("+s+")");

                alert(obj.name);
            }

        </script>
    </head>
    <body onload="f4();">

    </body>
</html>